cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)

project(blackeye)

# Options

#set(CMAKE_CXX_FLAGS "-Wall -O3")
if(WIN32)
	set(ENV{CMAKE_PREFIX_PATH}
		${CMAKE_BINARY_DIR}
		"/mingw/msys/1.0"
		"$ENV{SYSTEMDRIVE}"
		"$ENV{SYSTEMDRIVE}/usr"
		"$ENV{USERPROFILE}"
		"$ENV{PROGRAMFILES}"
		"$ENV{CMAKE_PREFIX_PATH}"
		)
#else(WIN32)
	#set(CMAKE_INSTALL_PREFIX /usr/local/games/aria)
	#set(RASPBERRYPI true)	# -DRASPBERRYPI=true
endif(WIN32)
#set(CMAKE_VERBOSE_MAKEFILE true)

add_subdirectory(src)

if(WIN32)
	set(DLLS
		gcc_s_dw2-1 
		stdc++-6
		SDL
		SDL_image
		SDL_mixer
		png15-15
		ogg-0
		vorbis-0
		vorbisfile-3
		zlib1
		physfs
		#gme
		)
	foreach(DLL ${DLLS})
		find_file(${DLL}_DLL 
			NAMES
				${DLL}.dll
				lib${DLL}.dll
			PATHS
				src/${DLL}
				/
				/usr
				/usr/local
				/mingw
				"$ENV{PATH}"
			PATH_SUFFIXES
				bin
				lib/x86
			)
		install(FILES ${${DLL}_DLL} DESTINATION .)
	endforeach(DLL)
endif(WIN32)

#find_program(HG hg)

if(HG)
	execute_process(COMMAND ${HG} status -camn dat img snd
		OUTPUT_VARIABLE ASSLIST
		OUTPUT_STRIP_TRAILING_WHITESPACE
		)
	string(REGEX MATCHALL "^.+$" ASSETS ${ASSLIST})
	install(FILES ${ASSLIST} DESTINATION .)
else(HG)
	install(DIRECTORY dat img snd DESTINATION .)
endif(HG)

set(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME})
include(CPack)
